package at.tasat.cnf;

public final class Literal {

	public static Integer toLiteral(int variableId, boolean phase) {
		assert isVariable(variableId);
		return phase ? variableId : -variableId;
	}

	public static int getVariableId(int literal) {
		return literal > 0 ? literal : -literal;
	}

	public static boolean getPhase(int literal) {
		return literal > 0;
	}

	public static boolean isTrue(int literal, boolean value) {
		return getPhase(literal) == value;
	}

	public static boolean isVariable(int variableId) {
		return variableId > 0;
	}

	public static boolean isLiteral(int literal) {
		return literal != 0;
	}

	private Literal() {
		//nothing to do
	}

}
